The technology described herein relates to a method of and apparatus for processing graphics, and in particular to a method and apparatus for use when processing graphics primitives to generate a render output in a graphics processing system.
As is known in the art, graphics processing is normally carried out by first splitting the scene to be displayed into a number of similar basic components or “primitives”, which primitives are then subjected to the desired graphics processing operations. The graphics “primitives” are usually in the form of simple polygons, such as triangles.
The primitives for an output such as a frame to be displayed are usually generated by the applications program interface for the graphics processing system, using the graphics drawing instructions (requests) received from the application (e.g. game) that requires the graphics processing.
Each primitive is at this stage usually defined by and represented as a set of vertices. Each vertex for a primitive has associated with it a set of data (such as position, colour, texture and other attributes data) representing the vertex. This data is then used, e.g., when rasterising and rendering the vertex (the primitive(s) to which the vertex relates), e.g. for display.
Once primitives and their vertices have been generated and defined, they can be processed by the graphics processing system, in order, e.g., to render the frame.
This process basically involves determining which sampling points of an array of sampling points covering the output area to be processed are covered by a primitive, and then determining the appearance each sampling point should have (e.g. in terms of its colour, etc.) to represent the primitive at that sampling point. These processes are commonly referred to as rasterising and rendering, respectively.
The rasterising process determines the sampling points that should be used for a primitive (i.e. the (x, y) positions of the sample points to be used to represent the primitive in the render output, e.g. frame to be displayed).
The rendering process then derives the data, such as red, green and blue (RGB) colour values and an “Alpha” (transparency) value, necessary to represent the primitive at the sample points (i.e. “shades” each sample point). This can involve, as is known in the art, applying textures, blending sample point data values, etc.
(In 3D graphics literature, the term “rasterisation” is sometimes used to mean both primitive conversion to sample positions and rendering. However, herein “rasterisation” will be used to refer to converting primitive data to sampling point addresses only.)
The rasterisation process basically maps the primitives defining the render output to be generated to the array of sampling points that will be used to render the output. This is typically done by determining, for each sampling point of the render output, whether the sampling point is covered by the primitive in question or not. This determination is typically done by testing the sampling points' positions against the edges of the primitive, to see if the sampling points are covered by the primitive. To do this, graphics processing systems typically derive (line) equations representing each of the edges of a primitive (e.g. using the defined vertices of the primitive), and then test the sampling points' positions using these edge equations. If a sampling point position “passes” the edge test, it is taken to be within the primitive. A positive value for the edge equation is usually taken to indicate that the sampling point is inside the edge in question (that the edge test is “passed”), a negative value for the edge equation is usually taken to indicate that the sampling point is outside the edge in question (that the edge test is “failed”), and a value of “0” may be taken to indicate that the sampling point is inside or outside the edge in question (that the edge test is passed or not), depending on the “tie-break” rule being used.
The rasterisation process is typically carried out by testing sets of one, or of more than one, sampling point. For each set of sampling points found to include a sample point that is covered by the primitive in question (being tested), a discrete graphical entity usually referred to as a “fragment” on which the graphics processing operations (such as rendering) are to be carried out is then generated by the rasteriser and sent to the rest of the graphics processing pipeline (such as the renderer) for processing.
Covered sampling points are thus, in effect, processed as fragments that will be used to render the primitive at the sampling points in question. The “fragments” are the graphical entities that pass through the rendering process (the rendering pipeline). Each fragment that is generated and processed may, e.g., represent a single sampling point or a set of plural sampling points, depending upon how the graphics processing system is configured.
(A “fragment” is therefore effectively (has associated with it) a set of primitive data as interpolated to a given output space sample point or points of a primitive. It may also include per primitive and other state data that is required to shade the primitive at the sample point (fragment position) in question. Each graphics fragment may typically be the same size and location as a “pixel” of the render output (e.g. output frame) (since as the pixels are the singularities in the final display, there may be a one to one mapping between the “fragments” the graphics processor operates on (renders) and the pixels of a display). However, it can be the case that there is not a one to one correspondence between a fragment and a display pixel, for example where particular forms of post processing, such as down-sampling, are carried out on the rendered image prior to displaying the final image.)
(It is also the case that as multiple fragments, e.g. from different overlapping primitives, at a given location may affect each other (e.g. due to transparency and/or blending), the final pixel output may depend upon plural or all fragments at that pixel location.)
(Correspondingly, there may be a one to one correspondence between the sampling points and the pixels of a display, but more typically there may not be a one to one correspondence between sampling points and display pixels, as down-sampling may be carried out on the rendered sample values to generate the output pixel values for displaying the final image. Similarly, where multiple sampling point values, e.g. from different overlapping primitives, at a given location affect each other (e.g. due to transparency and/or blending), the final pixel output will also depend upon plural overlapping sample values at that pixel location.)
Many graphics processing systems use so-called “tile-based” rendering. In tile-based rendering, the two-dimensional render output or target (i.e. the output of the rendering process, such as an output frame to be displayed) is rendered as a plurality of smaller area sub-regions, usually referred to as “tiles”. The tiles are each rendered separately (typically one after another). The rendered tiles are then combined to provide the complete rendering output (e.g. frame for display). In such arrangements, the render target (output) is typically divided (by area) into regularly-sized and shaped rendering tiles (they are usually e.g., squares or rectangles) but this is not essential.
Other terms that are commonly used for “tiling” and “tile-based” rendering include “chunking” (the rendering tiles are referred to as “chunks”) and “bucket” rendering. The terms “tile” and “tiling” will be used hereinafter for convenience, but it should be understood that these terms are intended to encompass all alternative and equivalent terms and techniques.
The advantage of such tile-based rendering is that primitives that do not appear in a given tile do not have to be processed for that tile, and therefore can be ignored when the tile is processed. This allows the overall amount of graphics processing necessary for a given render output to be reduced.
In order for a primitive to be rasterised and rendered, various information is provided and determined. As described above, each primitive is initially defined by and represented as a set of vertices. Each vertex for a primitive has associated with it a set of data (such as position, colour, texture and other attributes data) representing the vertex. In order for the rasterisation and rendering processes to be performed, various further data/information is determined from this initial set of data. This further data includes: edge equations, depth equations and barycentric interpolation equations. The edge equations define each edge of the primitive and are determined from its vertices. The depth equations are equations defining the relative depth of the primitive. The barycentric interpolation equations are the equations used for barycentric interpolation with barycentric coordinates at the rendering stage.
Usually, all of this information (edge equations, depth equations and barycentric interpolation equations) is determined at an initial primitive set-up stage which is performed before both rasterisation and rendering.
The Applicants believe that there remains scope for providing improved methods and apparatus for processing primitives when generating a render output in a graphics processing system.
A number of embodiments of the technology described herein will now be described.